package main

import (
    "fmt"
    "time"
)

var j int = 0
func Chann(ch chan int) {
    for {
        j++
        fmt.Println("send int ", j)
        ch <- j
        time.Sleep(time.Second)
    }
}
func stopChann(ch chan bool) {
    time.Sleep(10 * time.Millisecond)
    for {
        fmt.Println("check j ", j)
        if j == 6 {
            fmt.Println("send bool ")
            ch <- true
        }
        time.Sleep(time.Second)
    }
}

func main() {
    ch := make(chan int)
    c := 0
    stopCh := make(chan bool)

    go Chann(ch)
    go stopChann(stopCh)

    for {
        select {
        case c = <-ch:
            fmt.Println("Receive int: ", c)
        //case s := <-ch:
            //fmt.Println("Receive bool", s)
        case _ = <-stopCh:
            fmt.Println("stop")
            goto end
        }
    }
end:
    fmt.Println(j)
}